<template>
  <view>
    <view :style="'background: url(' + (path_s_url.length > 0 ? path_s_url : path_s) + ') no-repeat fixed;background-size: 100% 100%;'"
          class="container">
      <view class="drag"></view>
    </view>
    <view class="bodyy">
      <navigator
          :openType="pages.length == 1 ? 'switchTab' : 'navigateBack'"
          :style="'top:' + nTop + 'px'"
          :url="pages.length == 1 ? '/pages/index/index4' : ''"
          class="UgobackFix"
          hoverClass="none"
      >
        <view class="i ico">{{ pages.length == 1 ? '' : '' }}</view>
      </navigator>
      <view class="sitename">
        <view class="h1">{{ h1 }}</view>
        <view class="h5">{{ h5 }}</view>
      </view>
      <view class="loadbtm">
        <view v-if="ifwin" :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="cliadv" @tap="btnFn">
          手机号快捷登录
        </view>
        <button v-else :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="cliadv"
                openType="getPhoneNumber" @getphonenumber="getPhoneNumber">
          手机号快捷登录
        </button>
      </view>
      <view class="clause">
        <checkbox-group class="checkbox" @change="ifagreeFn">
          <label>
            <checkbox :color="color" name="ifagree" value="1"></checkbox>
            登录即表示同意
          </label>
          <navigator class="a" hoverClass="none" url="/pagesA/about/law?kind=tg_agreement">用户服务协议</navigator>
          和
          <navigator class="a" hoverClass="none" url="/pagesA/about/law?kind=tg_declara">个人隐私条款</navigator>
        </checkbox-group>
      </view>
    </view>
    <view v-if="div_login" class="mask1 alpha0_100">
      <view
          :style="'--div_box_width:75%;--div_box_height:550rpx;background:-webkit-linear-gradient(top,rgba(' + rgbcolor + ',.3),#fff 25%);background-color: #fff;'"
          class="div_box big_normal"
      >
        <view class="S18 h2">服务协议及隐私保护</view>
        <view class="S15">
          为了更好地保障您的合法权益，请您阅读并同意以下协议
          <navigator :style="'color:' + color + ';'" hoverClass="none" url="/pagesA/about/law?kind=tg_agreement">
            《用户服务协议》
          </navigator>
          和
          <navigator :style="'color:' + color + ';'" hoverClass="none" url="/pagesA/about/law?kind=tg_declara">
            《个人隐私条款》
          </navigator>
        </view>
        <button :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="btn5" openType="getPhoneNumber"
                @getphonenumber="getPhoneNumber">同意
        </button>
        <view class="C999 S18" @tap="back">不同意</view>
      </view>
    </view>
    <privacy-popup @agree="privacy_agree" @disagree="privacy_disagree"></privacy-popup>
  </view>
</template>
<script>
import privacyPopup from '../../components/privacyPopup/privacyPopup.vue';

var a;
var t = require('../../res/www.a9a.cn.js');
var app = getApp();
export default {
  components: {
    privacyPopup
  },
  data() {
    return {
      ifwin: true,
      tguid: '',
      loading: '',
      path_s: '',
      path_s_url: '',
      color: '',
      rgbcolor: '',
      h1: '',
      h5: '',
      MB: '',
      div_login: false,
      pages: [],
      nTop: ''
    };
  },
  onLoad: function (e) {
    var n = e.tguid;
    var g = e.admid;
    n = app.globalData.empty(n) ? 0 : n;
    g = app.globalData.empty(g) ? 0 : g;
    var that = this;
    a = uni.getStorageSync('COOK_U');
    console.log('tg-login->  tguid=' + n);
    console.log('tg-login->  admid=' + g);
    app.globalData.ajax({
      url: 'tg.php',
      data: {
        submitok: 'loading',
        openid: a.openid
      },
      success: function (a) {
        switch (a.flag) {
          case '1':
          case 1:
            switch (
                (that.setData({
                  tguid: n,
                  loading: a.loading,
                  path_s: a.loading.path_s,
                  path_s_url: a.loading.path_s_url,
                  color: a.color,
                  rgbcolor: t.c16_rgb(a.color),
                  h1: a.h1,
                  h5: a.h5,
                  MB: a.MB
                }),a.t)) {
              case 'flag0':
              case 'flag_1':
              case 'flag2':
                uni.reLaunch({
                  url: 'reg?t=' + a.t
                });
                break;
              case 'flag1':
                uni.reLaunch({
                  url: 'my'
                });
            }
            break;
          default:
            uni.showToast({
              title: a.msg,
              icon: 'none',
              mask: true
            });
        }
      }
    });
    app.globalData.get_navigationBarTopHeight(this);
  },
  onShareAppMessage: function () {
    return {
      imageUrl: this.loading.share.imgurl,
      title: this.loading.share.title,
      path: '/hnPages/tg/login'
    };
  },
  onShareTimeline: function () {
    return {
      imageUrl: this.loading.share.imgurl,
      title: this.loading.share.title,
      query: '',
      path: '/hnPages/tg/login'
    };
  },
  methods: {
    ifagreeFn: function (a) {
      1 == a.detail.value
          ? this.setData({
            ifwin: false
          })
          : this.setData({
            ifwin: true
          });
    },

    btnFn: function () {
      t.empty(this.MB) || app.globalData.openSetting(this.MB);
      this.setData({
        div_login: true
      });
    },

    back: function () {
      this.setData({
        div_login: false
      });
    },

    getPhoneNumber: function (a) {
      var t = this.tguid;
      app.globalData.getPhoneNumber({
        e: a,
        submitok: 'tg_reg_addupdate',
        tguid: t,
        url: 'reg',
        urlkind: 'reLaunch'
      });
    },

    privacy_agree: function (a) {
      console.log('agree');
    },

    privacy_disagree: function (a) {
      console.log('disagree');
      uni.exitMiniProgram();
    }
  }
};
</script>
<style>
@import 'login.css';
</style>
